﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using Component;

public partial class FrontEnd_Body_Center_CartDetail : System.Web.UI.UserControl
{
    public bool _existsCart = false;
    public int _dem = 0;
    protected void Page_Load(object sender, EventArgs e)
    {
            if (Sessions.IdProducts != "")
                _existsCart = true;
            this.dlCartDetail.DataSource = GetCart();
            this.dlCartDetail.DataBind();
        if (QueryHelper.GetQueryString(Request, ConstString._LienHeGia).Trim() == ConstString._LienHeGia)
            _existsCart = false;
    }
    public ArrayList GetCart()
    {
        ArrayList al = new ArrayList();
        string alIdProduct = Sessions.IdProducts;
        while (alIdProduct.Length > 0)
        {
            CartInfo _cartProduct = new CartInfo();
            string idTam = alIdProduct.Split(';')[0];
            string id =ConvertType.ToString(idTam);
            if (ConvertType.ToInt(id) >= 0)
            {
                int tam1 = alIdProduct.Replace(";","").Length;
                alIdProduct = alIdProduct.Replace(idTam+";", "");
                int tam2 = alIdProduct.Replace(";", "").Length;
                _cartProduct.Product = ProductDB.GetObjectByid(ConvertType.ToInt(id), false);
                _cartProduct.NameProduct = Component.Languages.GetContentByLanguage(_cartProduct.Product.NameEL, _cartProduct.Product.Name);
                //if (Sessions.LanguageVN == false) _cartProduct.NameProduct = _cartProduct.Product.NameEL;
                //else
                //    _cartProduct.NameProduct = _cartProduct.Product.Name;
                _cartProduct.Cart = null;
                _cartProduct.Quantity = tam1 - tam2;
                al.Add(_cartProduct);
            }
        }
        return al;
    }
  
}
